home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / iutil / get_reltup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-01-23  |  1.3 KB  |  53 lines

  1. # include <ingres.h>
  2. # include <access.h>
  3. # include <aux.h>
  4. # include <sccs.h>
  5.  
  6. SCCSID(@(#)get_reltup.c    8.1    12/31/84)
  7.  
  8. /*
  9. **  GET_RELTUP -- get appropriate tuple from relation catalog
  10. **
  11. **    Get the tuple for the relation specified by 'name'
  12. **    and put it in the descriptor 'dx'.
  13. **
  14. **    First a relation named 'name' owned
  15. **    by the current user is searched for. If that fails,
  16. **    then a relation owned by the dba is searched for.
  17. */
  18.  
  19. get_reltup(d, name)
  20. register DESC    *d;
  21. char        *name;
  22. {
  23.     struct relation    rel;
  24.     register int    i;
  25.  
  26.     clearkeys(&Admin.adreld);
  27.  
  28.     /* make believe relation relation is read only for concurrency */
  29.     Admin.adreld.relopn = abs(Admin.adreld.relopn);
  30.  
  31.     /* relation relation is open. Search for relation 'name' */
  32.     setkey(&Admin.adreld, (char *) &rel, name, RELID);
  33.     setkey(&Admin.adreld, (char *) &rel, Usercode, RELOWNER);
  34.  
  35.     if ((i = getequal(&Admin.adreld, (char *) &rel, d, &d->reltid.s_tupid)) == 1)
  36.     {
  37.         /* not a user relation. try relation owner by dba */
  38.         setkey(&Admin.adreld, (char *) &rel, Admin.adhdr.adowner, RELOWNER);
  39.         i = getequal(&Admin.adreld, (char *) &rel, d, &d->reltid.s_tupid);
  40.     }
  41.  
  42.     flush_rel(&Admin.adreld, TRUE);
  43.  
  44. #    ifdef xATR1
  45.     if (tTf(21, 1))
  46.         printf("get_reltup: %d\n", i);
  47. #    endif
  48.  
  49.     /* restore relation relation to read/write mode */
  50.     Admin.adreld.relopn = -Admin.adreld.relopn;
  51.     return (i);
  52. }
  53.